﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Windows;

namespace BDSim
{
    public class DataSaveFlagModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;


        private string _Name;
        /// <summary>
        /// 选项名称
        /// </summary>
        public string Name
        {
            get { return _Name; }
            set { _Name = value; if (this.PropertyChanged != null) this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Name")); }
        }


        
        Visibility _IsVisible = Visibility.Visible;
        /// <summary>
        /// 选项是否可见
        /// </summary>
        public Visibility IsVisible
        {
            get { return _IsVisible; }
            set { 
                _IsVisible = value;
                if (value == Visibility.Collapsed)
                {
                    IsEnable = false;
                }
                if (this.PropertyChanged != null)
                    this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsVisible"));
            }
        }

        bool _IsEnable = true;
        /// <summary>
        /// 选项是否可用
        /// </summary>
        public bool IsEnable
        {
            get { return _IsEnable; }
            set
            {
                _IsEnable = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Enable"));
                for (int i = 0; i < SubModelList.Count; i++)
                {
                    SubModelList[i].IsEnable = value;
                }
                if (!value)
                {
                    IsChecked = false;
                }
            }
        }

        bool _IsChecked = true;
        /// <summary>
        /// 选项是否选择
        /// </summary>
        public bool IsChecked
        {
            get { return _IsChecked; }
            set
            {
                _IsChecked = value;
                if (this.PropertyChanged != null)
                    this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsChecked"));
                for (int i = 0; i < SubModelList.Count; i++)
                {
                    SubModelList[i].IsChecked = value;
                }
            }
        }

        private ObservableCollection<DataSaveFlagModel> _SubModel = new ObservableCollection<DataSaveFlagModel>();
        /// <summary>
        /// 子选项
        /// </summary>
        public ObservableCollection<DataSaveFlagModel> SubModelList
        {
            get { return _SubModel; }
            set { _SubModel = value; if (this.PropertyChanged != null) this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("SubModel")); }
        }


    }
}
